<template>
    <div class="my-bottles-page">

        <!-- 统计信息 -->
        <div class="stats-section">
            <div class="stat-card">
                <div class="stat-number">{{ sentBottles.length || 0 }}</div>
                <div class="stat-label">已发出</div>
            </div>
            <div class="stat-card">
                <div class="stat-number">{{ receivedReplies.length || 0 }}</div>
                <div class="stat-label">收到回复</div>
            </div>
            <div class="stat-card">
                <div class="stat-number">{{ totalLikes || 0 }}</div>
                <div class="stat-label">获得点赞</div>
            </div>
        </div>

        <!-- 瓶子列表 -->
        <div class="bottles-section">
            <div class="section-header">
                <h2>我发出的瓶子</h2>
                <div class="filter-tabs">
                    <button v-for="tab in filterTabs" :key="tab.key" class="filter-tab"
                        :class="{ active: activeFilter === tab.key }" @click="activeFilter = tab.key">
                        {{ tab.label }}
                    </button>
                </div>
            </div>

            <div class="bottles-list">
                <div v-for="bottle in filteredBottles" :key="bottle.id" class="bottle-card"
                    :class="{ 'has-replies': bottle.replies.length > 0 }">
                    <div class="bottle-header">
                        <div class="bottle-meta">
                            <h3 class="bottle-title">{{ bottle.title || '无标题' }}</h3>
                            <div class="bottle-info">
                                <span class="bottle-time">{{ formatTime(bottle.createdAt) }}</span>
                                <span class="bottle-location" v-if="bottle.location">{{ bottle.location }}</span>
                            </div>
                        </div>
                        <div class="bottle-status">
                            <span class="status-badge" :class="getStatusClass(bottle.status)">
                                {{ getStatusText(bottle.status) }}
                            </span>
                        </div>
                    </div>

                    <div class="bottle-content">
                        <p class="bottle-text">{{ bottle.content }}</p>
                        <div class="bottle-tags" v-if="bottle.tags">
                            <span v-for="tag in bottle.tags" :key="tag" class="tag">{{ tag }}</span>
                        </div>
                    </div>

                    <div class="bottle-stats">
                        <div class="stat-item">
                            <span class="stat-icon">❤️</span>
                            <span>{{ bottle.likes || 0 }}</span>
                        </div>
                        <div class="stat-item">
                            <span class="stat-icon">💬</span>
                            <span>{{ bottle.replies.length }}</span>
                        </div>
                    </div>

                    <!-- 回复列表 -->
                    <div v-if="bottle.replies.length > 0" class="replies-section">
                        <div class="replies-header">
                            <h4>收到的回复 ({{ bottle.replies.length }})</h4>
                        </div>
                        <div class="replies-list">
                            <div v-for="reply in bottle.replies" :key="reply.id" class="reply-item">
                                <div class="reply-avatar">
                                    <img :src="reply.avatar" :alt="reply.username" />
                                </div>
                                <div class="reply-content">
                                    <div class="reply-header">
                                        <span class="reply-username">{{ reply.username }}</span>
                                        <span class="reply-time">{{ formatTime(reply.createdAt) }}</span>
                                    </div>
                                    <p class="reply-text">{{ reply.content }}</p>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="bottle-actions">
                        <button class="action-btn edit-btn" @click="editBottle(bottle)" title="编辑瓶子">
                            <svg width="18" height="18" viewBox="0 0 24 24" fill="none">
                                <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"
                                    stroke="currentColor" stroke-width="2" />
                                <path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z" stroke="currentColor"
                                    stroke-width="2" />
                            </svg>
                        </button>
                        <button class="action-btn delete-btn" @click="deleteBottleHandler(bottle.id)" title="删除瓶子">
                            <svg width="18" height="18" viewBox="0 0 24 24" fill="none">
                                <path
                                    d="M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"
                                    stroke="currentColor" stroke-width="2" />
                            </svg>
                        </button>
                    </div>
                </div>

                <!-- 空状态 -->
                <div v-if="filteredBottles.length === 0" class="empty-state">
                    <div class="empty-icon">🌊</div>
                    <h3>还没有发出瓶子</h3>
                    <p>扔出你的第一个瓶子，开始你的漂流之旅吧！</p>
                    <button class="primary-btn" @click="showThrowModal = true">
                        <svg width="20" height="20" viewBox="0 0 24 24" fill="none">
                            <path d="M12 5v14M5 12h14" stroke="currentColor" stroke-width="2" stroke-linecap="round"
                                stroke-linejoin="round" />
                        </svg>
                        扔出第一个瓶子
                    </button>
                </div>
            </div>
        </div>

        <!-- 扔瓶子弹窗 -->
        <div v-if="showThrowModal" class="modal-overlay" @click="showThrowModal = false">
            <div class="throw-modal" @click.stop>
                <div class="modal-header">
                    <h3>🌊 扔瓶子</h3>
                    <button class="close-btn" @click="showThrowModal = false">×</button>
                </div>
                <div class="modal-content">
                    <div class="form-group">
                        <label>标题</label>
                        <input v-model="newBottleTitle" type="text" placeholder="给你的瓶子起个标题..." maxlength="20">
                    </div>

                    <div class="form-group">
                        <label>内容 <span class="required">*</span></label>
                        <textarea v-model="newBottleContent" placeholder="写下你想分享的内容..." rows="6"
                            maxlength="500"></textarea>
                        <div class="char-count">{{ newBottleContent.length }}/500</div>
                    </div>

                    <div class="form-group">
                        <label>标签</label>
                        <input v-model="newBottleTags" type="text" placeholder="用逗号分隔，如：运动,健身,跑步" maxlength="50">
                    </div>

                    <div class="form-group">
                        <label>位置</label>
                        <input v-model="newBottleLocation" type="text" placeholder="你在哪里？" maxlength="30">
                    </div>

                    <div class="form-group">
                        <label>心情</label>
                        <div class="mood-selector">
                            <label class="mood-option" :class="{ active: newBottleMood === 'happy' }">
                                <input v-model="newBottleMood" type="radio" value="happy">
                                <span>😊 开心</span>
                            </label>
                            <label class="mood-option" :class="{ active: newBottleMood === 'excited' }">
                                <input v-model="newBottleMood" type="radio" value="excited">
                                <span>🤩 兴奋</span>
                            </label>
                            <label class="mood-option" :class="{ active: newBottleMood === 'peaceful' }">
                                <input v-model="newBottleMood" type="radio" value="peaceful">
                                <span>😌 平静</span>
                            </label>
                            <label class="mood-option" :class="{ active: newBottleMood === 'motivated' }">
                                <input v-model="newBottleMood" type="radio" value="motivated">
                                <span>💪 励志</span>
                            </label>
                        </div>
                    </div>
                </div>
                <div class="modal-actions">
                    <button class="cancel-btn" @click="showThrowModal = false" :disabled="isThrowing">取消</button>
                    <button class="confirm-btn" @click="throwBottle" :disabled="isThrowing">
                        <span v-if="isThrowing">扔出中...</span>
                        <span v-else>🌊 扔出瓶子</span>
                    </button>
                </div>
            </div>
        </div>

        <!-- 编辑瓶子弹窗 -->
        <div v-if="showEditModal" class="modal-overlay" @click="showEditModal = false">
            <div class="throw-modal" @click.stop>
                <div class="modal-header">
                    <h3>✏️ 编辑瓶子</h3>
                    <button class="close-btn" @click="showEditModal = false">×</button>
                </div>
                <div class="modal-content">
                    <div class="form-group">
                        <label>标题</label>
                        <input v-model="newBottleTitle" type="text" placeholder="给你的瓶子起个标题..." maxlength="20">
                    </div>

                    <div class="form-group">
                        <label>内容 <span class="required">*</span></label>
                        <textarea v-model="newBottleContent" placeholder="写下你想分享的内容..." rows="6"
                            maxlength="500"></textarea>
                        <div class="char-count">{{ newBottleContent.length }}/500</div>
                    </div>

                    <div class="form-group">
                        <label>标签</label>
                        <input v-model="newBottleTags" type="text" placeholder="用逗号分隔，如：运动,健身,跑步" maxlength="50">
                    </div>

                    <div class="form-group">
                        <label>位置</label>
                        <input v-model="newBottleLocation" type="text" placeholder="你在哪里？" maxlength="30">
                    </div>

                    <div class="form-group">
                        <label>心情</label>
                        <div class="mood-selector">
                            <label class="mood-option" :class="{ active: newBottleMood === 'happy' }">
                                <input v-model="newBottleMood" type="radio" value="happy">
                                <span>😊 开心</span>
                            </label>
                            <label class="mood-option" :class="{ active: newBottleMood === 'excited' }">
                                <input v-model="newBottleMood" type="radio" value="excited">
                                <span>🤩 兴奋</span>
                            </label>
                            <label class="mood-option" :class="{ active: newBottleMood === 'peaceful' }">
                                <input v-model="newBottleMood" type="radio" value="peaceful">
                                <span>😌 平静</span>
                            </label>
                            <label class="mood-option" :class="{ active: newBottleMood === 'motivated' }">
                                <input v-model="newBottleMood" type="radio" value="motivated">
                                <span>💪 励志</span>
                            </label>
                        </div>
                    </div>
                </div>
                <div class="modal-actions">
                    <button class="cancel-btn" @click="showEditModal = false" :disabled="isEditing">取消</button>
                    <button class="confirm-btn" @click="saveEdit" :disabled="isEditing">
                        <span v-if="isEditing">保存中...</span>
                        <span v-else>💾 保存修改</span>
                    </button>
                </div>
            </div>
        </div>

        <!-- 自定义提示框 -->
        <div v-if="showToast" class="toast-container">
            <div class="toast" :class="`toast-${toastType}`">
                <div class="toast-icon">
                    <span v-if="toastType === 'success'">✅</span>
                    <span v-else-if="toastType === 'error'">❌</span>
                    <span v-else-if="toastType === 'warning'">⚠️</span>
                    <span v-else-if="toastType === 'info'">ℹ️</span>
                </div>
                <div class="toast-message">{{ toastMessage }}</div>
                <button class="toast-close" @click="showToast = false">×</button>
            </div>
        </div>

        <!-- 删除确认对话框 -->
        <div v-if="showDeleteConfirm" class="modal-overlay" @click="cancelDelete">
            <div class="confirm-modal" @click.stop>
                <div class="confirm-header">
                    <h3>🗑️ 确认删除</h3>
                </div>
                <div class="confirm-content">
                    <p>确定要删除这个瓶子吗？</p>
                    <p class="confirm-warning">此操作不可恢复！</p>
                </div>
                <div class="confirm-actions">
                    <button class="confirm-btn cancel" @click="cancelDelete">取消</button>
                    <button class="confirm-btn delete" @click="confirmDelete">删除</button>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
import { ref, computed, onMounted, watch, nextTick } from 'vue'
import { useRouter } from 'vue-router'

const router = useRouter()

// 使用本地数据存储
const sentBottles = ref([])

onMounted(() => {
    // 页面加载时的初始化逻辑
    // 从本地存储加载数据
    try {
        const stored = localStorage.getItem('drift-bottle-data')
        if (stored) {
            const parsed = JSON.parse(stored)
            // 将日期字符串转换回Date对象
            sentBottles.value = parsed.map(bottle => ({
                ...bottle,
                createdAt: new Date(bottle.createdAt),
                replies: bottle.replies.map(reply => ({
                    ...reply,
                    createdAt: new Date(reply.createdAt)
                }))
            }))
        }
    } catch (error) {
        console.error('加载本地数据失败:', error)
    }
    
    // 根据路由路径设置页面标题
    if (window.location.pathname.includes('/drift-bottle/my-bottles')) {
        document.title = '发出的瓶子 - 运动漂流瓶'
    } else if (window.location.pathname.includes('/drift-bottle/received')) {
        document.title = '收到的瓶子 - 运动漂流瓶'
    }
})

// 监听数据变化，自动保存到本地存储
watch(sentBottles, (newData) => {
    try {
        localStorage.setItem('drift-bottle-data', JSON.stringify(newData))
    } catch (error) {
        console.error('保存到本地存储失败:', error)
    }
}, { deep: true })

// 响应式数据
const showThrowModal = ref(false)
const showEditModal = ref(false)
const editingBottle = ref(null)
const newBottleTitle = ref('')
const newBottleContent = ref('')
const newBottleTags = ref('')
const newBottleLocation = ref('')
const newBottleMood = ref('happy')
const isThrowing = ref(false)
const isEditing = ref(false)
const activeFilter = ref('all')

// 提示框相关
const showToast = ref(false)
const toastMessage = ref('')
const toastType = ref('success') // success, error, warning, info

// 计算属性
const receivedReplies = computed(() => {
    return sentBottles.value.reduce((total, bottle) => total + bottle.replies.length, 0)
})

const totalLikes = computed(() => {
    return sentBottles.value.reduce((total, bottle) => total + bottle.likes, 0)
})

const filterTabs = [
    { key: 'all', label: '全部' },
    { key: 'active', label: '活跃' },
    { key: 'replied', label: '有回复' },
    { key: 'popular', label: '热门' }
]

const filteredBottles = computed(() => {
    let filtered = sentBottles.value

    switch (activeFilter.value) {
        case 'active':
            filtered = filtered.filter(bottle => bottle.status === 'active')
            break
        case 'replied':
            filtered = filtered.filter(bottle => bottle.replies.length > 0)
            break
        case 'popular':
            filtered = filtered.filter(bottle => bottle.likes >= 10)
            break
    }

    return filtered.sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt))
})

// 方法

const formatTime = (date) => {
    const now = new Date()
    const diff = now - date
    const days = Math.floor(diff / (1000 * 60 * 60 * 24))

    if (days === 0) {
        return '今天'
    } else if (days === 1) {
        return '昨天'
    } else if (days < 7) {
        return `${days}天前`
    } else {
        return date.toLocaleDateString()
    }
}

const getStatusClass = (status) => {
    switch (status) {
        case 'active': return 'status-active'
        case 'replied': return 'status-replied'
        case 'popular': return 'status-popular'
        default: return 'status-default'
    }
}

const getStatusText = (status) => {
    switch (status) {
        case 'active': return '活跃中'
        case 'replied': return '有回复'
        case 'popular': return '热门'
        default: return '正常'
    }
}

const viewBottle = (bottle) => {
    // 增加浏览量
    incrementViews(bottle.id)
    // 这里可以跳转到瓶子详情页
    console.log('查看瓶子:', bottle)
}

const editBottle = (bottle) => {
    editingBottle.value = bottle
    newBottleTitle.value = bottle.title
    newBottleContent.value = bottle.content
    newBottleTags.value = bottle.tags.join(', ')
    newBottleLocation.value = bottle.location
    newBottleMood.value = bottle.mood
    showEditModal.value = true
}

const saveEdit = async () => {
    if (!newBottleContent.value.trim()) {
        showToastMessage('请输入瓶子内容', 'warning')
        return
    }

    isEditing.value = true

    try {
        // 模拟保存过程
        await new Promise(resolve => setTimeout(resolve, 1000))

        // 更新瓶子数据
        const bottleIndex = sentBottles.value.findIndex(b => b.id === editingBottle.value.id)
        if (bottleIndex > -1) {
            const updatedBottle = {
                ...sentBottles.value[bottleIndex],
                title: newBottleTitle.value,
                content: newBottleContent.value,
                tags: newBottleTags.value ? newBottleTags.value.split(',').map(tag => tag.trim()) : [],
                location: newBottleLocation.value,
                mood: newBottleMood.value
            }
            sentBottles.value.splice(bottleIndex, 1, updatedBottle)
            
            // 重置表单
            showEditModal.value = false
            editingBottle.value = null
            newBottleContent.value = ''
            newBottleTitle.value = ''
            newBottleTags.value = ''
            newBottleLocation.value = ''
            newBottleMood.value = 'happy'
            showToastMessage('瓶子已更新！', 'success')
        } else {
            showToastMessage('更新失败', 'error')
        }
    } catch (error) {
        console.error('更新瓶子失败:', error)
        showToastMessage('更新失败，请重试', 'error')
    } finally {
        isEditing.value = false
    }
}

// 显示提示框
const showToastMessage = (message, type = 'success') => {
    toastMessage.value = message
    toastType.value = type
    showToast.value = true

    // 3秒后自动隐藏
    setTimeout(() => {
        showToast.value = false
    }, 3000)
}

// 确认删除对话框
const showDeleteConfirm = ref(false)
const bottleToDelete = ref(null)

const deleteBottleHandler = (bottleId) => {
    bottleToDelete.value = bottleId
    showDeleteConfirm.value = true
}

const confirmDelete = () => {
    if (bottleToDelete.value) {
        const index = sentBottles.value.findIndex(bottle => bottle.id === bottleToDelete.value)
        if (index > -1) {
            sentBottles.value.splice(index, 1)
            showToastMessage('瓶子已删除', 'success')
        } else {
            showToastMessage('删除失败', 'error')
        }
    }
    showDeleteConfirm.value = false
    bottleToDelete.value = null
}

const cancelDelete = () => {
    showDeleteConfirm.value = false
    bottleToDelete.value = null
}

const incrementViews = (bottleId) => {
    const bottle = sentBottles.value.find(b => b.id === bottleId)
    if (bottle) {
        bottle.views = (bottle.views || 0) + 1
    }
}

const toggleLike = (bottleId) => {
    const bottle = sentBottles.value.find(b => b.id === bottleId)
    if (bottle) {
        bottle.isLiked = !bottle.isLiked
        bottle.likes += bottle.isLiked ? 1 : -1
        return bottle.isLiked
    }
    return false
}

const addReply = (bottleId, replyData) => {
    const bottle = sentBottles.value.find(b => b.id === bottleId)
    if (bottle) {
        const newReply = {
            id: Date.now(),
            username: replyData.username || '匿名用户',
            avatar: replyData.avatar || '/src/assets/images/avatar_default.png',
            content: replyData.content,
            createdAt: new Date()
        }
        bottle.replies.push(newReply)
        return newReply
    }
    return null
}

const throwBottle = async () => {
    if (!newBottleContent.value.trim()) {
        showToastMessage('请输入瓶子内容', 'warning')
        return
    }

    isThrowing.value = true

    try {
        // 模拟发送瓶子的过程
        await new Promise(resolve => setTimeout(resolve, 2000))

        // 添加新瓶子到本地数据
        const newBottle = {
            id: Date.now(),
            title: newBottleTitle.value || '无标题',
            content: newBottleContent.value,
            tags: newBottleTags.value ? newBottleTags.value.split(',').map(tag => tag.trim()) : [],
            location: newBottleLocation.value || '',
            mood: newBottleMood.value || 'happy',
            status: 'active',
            createdAt: new Date(),
            views: 0,
            likes: 0,
            replies: [],
            isUserBottle: true
        }
        
        sentBottles.value.unshift(newBottle)

        console.log('瓶子已成功扔出:', newBottle)

        // 重置表单
        showThrowModal.value = false
        newBottleContent.value = ''
        newBottleTitle.value = ''
        newBottleTags.value = ''
        newBottleLocation.value = ''
        newBottleMood.value = 'happy'

        showToastMessage('瓶子已成功扔出！', 'success')
    } catch (error) {
        console.error('扔瓶子失败:', error)
        showToastMessage('扔瓶子失败，请重试', 'error')
    } finally {
        isThrowing.value = false
    }
}

</script>

<style scoped>

.stats-section {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.stat-number {
    font-size: 32px;
    font-weight: 700;
    color: white;
    margin-bottom: 8px;
}

.stat-label {
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
}

.bottles-section {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.section-header h2 {
    color: white;
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.filter-tabs {
    display: flex;
    gap: 8px;
}

.filter-tab {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 25px;
    padding: 10px 20px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.filter-tab::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.6s;
}

.filter-tab:hover::before {
    left: 100%;
}

.filter-tab:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 0.9);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.filter-tab.active {
    background: #2ab465;
    color: white;
    font-weight: 600;
    transform: translateY(-2px);
}

.filter-tab.active:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.4);
}

.bottles-list {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 400px);
    gap: 20px;
    overflow-y: auto;
    padding-right: 8px;
}


/* Firefox 隐藏滚动条 */
.bottles-list {
    scrollbar-width: none;
}

.bottle-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 24px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.bottle-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.bottle-card.has-replies {
    border-left: 4px solid #4ade80;
}

.bottle-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.bottle-title {
    color: white;
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 600;
}

.bottle-info {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
}

.status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}


.bottle-content {
    margin-bottom: 16px;
}

.bottle-text {
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.6;
    margin: 0 0 12px 0;
}

.bottle-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
}

.bottle-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 16px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 4px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
}

.replies-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.replies-header h4 {
    color: white;
    margin: 0 0 12px 0;
    font-size: 16px;
}

.replies-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.reply-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
}

.reply-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.reply-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.reply-content {
    flex: 1;
}

.reply-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.reply-username {
    color: white;
    font-weight: 500;
    font-size: 14px;
}

.reply-time {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
}

.reply-text {
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    line-height: 1.4;
    margin: 0;
}

.bottle-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

.action-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.action-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s;
}

.action-btn:hover::before {
    transform: translateX(100%);
}

.edit-btn {
    background: #27ac92;
    color: white;
    box-shadow: 0 4px 15px rgba(240, 147, 251, 0.3);
}

.edit-btn:hover {
    transform: translateY(-2px) scale(1.05);
}

.delete-btn {
    color: #27ac92;
    box-shadow: 0 4px 15px rgba(255, 154, 158, 0.3);
}

.delete-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 25px rgba(255, 154, 158, 0.4);
    color: #b02a5b;
}

.action-btn:active {
    transform: translateY(0) scale(0.95);
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: white;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.empty-state h3 {
    margin: 0 0 8px 0;
    font-size: 20px;
}

.empty-state p {
    margin: 0 0 24px 0;
    color: rgba(255, 255, 255, 0.7);
}

.primary-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 24px;
    padding: 12px 24px;
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.primary-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

/* 模态框样式 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.throw-modal {
    background: white;
    border-radius: 20px;
    padding: 0;
    min-width: 500px;
    max-width: 600px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.modal-header {
    background: linear-gradient(135deg, #2ECC71 0%, #27AE60 100%);
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(46, 204, 113, 0.2);
}

.modal-header h3 {
    color: white;
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.modal-content {
    padding: 30px;
    max-height: 60vh;
    overflow-y: auto;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    color: #2c3e50;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
}

.required {
    color: #ff6b6b;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 16px;
    background: #f8f9fa;
    color: #2c3e50;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: #6c757d;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #2ECC71;
    background: white;
    box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.1);
}

.char-count {
    text-align: right;
    color: #6c757d;
    font-size: 12px;
    margin-top: 5px;
}

.mood-selector {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.mood-option {
    display: flex;
    align-items: center;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    background: #f8f9fa;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mood-option:hover {
    background: #e9ecef;
    border-color: #2ECC71;
}

.mood-option.active {
    background: #2ECC71;
    border-color: #27AE60;
}

.mood-option input {
    display: none;
}

.mood-option span {
    color: #2c3e50;
    font-size: 14px;
    font-weight: 500;
}

.mood-option.active span {
    color: white;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding: 20px 30px;
    background: rgba(255, 255, 255, 0.05);
}

.cancel-btn,
.confirm-btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    border: 1px solid #dee2e6;
}

.cancel-btn {
    background: #f8f9fa;
    color: #6c757d;
    border-color: #dee2e6;
}

.confirm-btn {
    background: #2ECC71;
    color: white;
    border-color: #2ECC71;
}

.confirm-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 自定义提示框样式 */
.toast-container {
    position: fixed;
    top: 100px;
    right: 20px;
    z-index: 999999999 !important;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    min-width: 300px;
    max-width: 400px;
    animation: slideInRight 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
}

.toast-success {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.9) 0%, rgba(22, 163, 74, 0.9) 100%);
    color: white;
}

.toast-error {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.9) 0%, rgba(220, 38, 38, 0.9) 100%);
    color: white;
}

.toast-warning {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.9) 0%, rgba(217, 119, 6, 0.9) 100%);
    color: white;
}

.toast-info {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.9) 0%, rgba(37, 99, 235, 0.9) 100%);
    color: white;
}

.toast-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.toast-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* 确认对话框样式 */
.confirm-modal {
    background: white;
    border-radius: 16px;
    padding: 0;
    min-width: 400px;
    max-width: 500px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    animation: scaleIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.confirm-header {
    background: linear-gradient(135deg, #2ECC71 0%, #27AE60 100%);
    padding: 20px 24px;
    text-align: center;
}

.confirm-header h3 {
    color: white;
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.confirm-content {
    padding: 24px;
    text-align: center;
}

.confirm-content p {
    margin: 0 0 8px 0;
    color: #2c3e50;
    font-size: 16px;
}

.confirm-warning {
    color: #e74c3c !important;
    font-weight: 600;
    font-size: 14px !important;
}

.confirm-actions {
    display: flex;
    gap: 12px;
    padding: 20px 24px;
    background: #f8f9fa;
}

.confirm-actions .confirm-btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.confirm-actions .confirm-btn.cancel {
    background: #6c757d;
    color: white;
}

.confirm-actions .confirm-btn.cancel:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

.confirm-actions .confirm-btn.delete {
    background: #2ECC71;
    color: white;
}

.confirm-actions .confirm-btn.delete:hover {
    background: #27AE60;
    transform: translateY(-1px);
}

@keyframes scaleIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

@media (max-width: 768px) {
    .header-content {
        padding: 0 16px;
    }

    .stats-section {
        padding: 0 16px;
        grid-template-columns: 1fr;
    }

    .bottles-section {
        padding: 0 16px;
    }

    .section-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }

    .filter-tabs {
        width: 100%;
        justify-content: space-between;
        gap: 6px;
    }

    .filter-tab {
        padding: 8px 16px;
        font-size: 13px;
        flex: 1;
        text-align: center;
    }

    .bottle-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .bottle-actions {
        justify-content: flex-start;
        gap: 6px;
    }

    .action-btn {
        width: 36px;
        height: 36px;
    }

    .throw-modal {
        min-width: 300px;
        max-width: 90vw;
        margin: 20px;
    }

    .modal-content {
        padding: 20px;
    }

    .modal-actions {
        padding: 16px 20px;
    }

    .toast-container {
        top: 80px;
        right: 10px;
        left: 10px;
    }

    .toast {
        min-width: 280px;
        max-width: 100%;
        margin: 0;
    }

    .confirm-modal {
        min-width: 300px;
        max-width: 90vw;
        margin: 20px;
    }

    .bottles-list {
        max-height: calc(100vh - 450px);
    }
}
</style>
